import shapefile

w = shapefile.Writer(shapeType=5)
w.autoBalance = 1

w.poly(shapeType=5, parts=[[[4,5], [10,5], [10,10], [4,10], [4,5]]])
w.field('Name', 'C', '40')
w.record('polygon1')
w.poly(shapeType=5, parts=[[[8,2], [15,2], [15,15], [8,15], [8,2]]])
w.record('polygon2')
w.save('mysampleshape.shp')